package com.qf.service.impl;

import com.qf.dao.UserDao;
import com.qf.dao.impl.UserDaoImpl;
import com.qf.entity.User;
import com.qf.service.UserService;
import com.qf.util.DruidUtil;

/*
杨威
2021/10/5
9:13
*/
public class UserServiceImpl implements UserService {

    UserDao userDao=new UserDaoImpl();
    @Override
    public User login(String username, String password) {
        User user = userDao.select(username);
        if(user!=null){
            if(!user.getPassword().equals(password)){
                DruidUtil.close();
                return null;
            }
        }
        DruidUtil.close();
        return user;
    }

    @Override
    public int updatePassword(String rePassword) {
        try {
            DruidUtil.close();
            return userDao.update(rePassword);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }
}
